home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / boosters.arc / WORDS.PAS < prev    next >
Pascal/Delphi Source File  |  1985-11-13  |  574b  |  23 lines

  1. { ---------------------------------------
  2.   WORDS returns the number of words in S.
  3.   --------------------------------------- }
  4. Function Words ( S : AnyString ) : Integer;
  5. var
  6.    NumWords,  CurrentAddress, Len
  7.              : integer;
  8.  
  9. begin
  10.    S := strip(S,' ');
  11.    Len := Length(S);
  12.    if Len = 0 then
  13.       Words := 0
  14.    else
  15.    begin
  16.       NumWords := 1;
  17.       CurrentAddress := 1;
  18.       for CurrentAddress := 1 to Len do
  19.          if S[CurrentAddress] = #32 then
  20.             NumWords := NumWords + 1;
  21.       Words := NumWords;
  22.    end;
  23. end { Words };